<template>
  <div>
    <div v-for="item in list">
        <p>{{item}}</p>
    </div>
      <button @click="clickAction">emit传值给父亲</button>
  </div>
</template>

<script>
export default {
    name:"HelloWorld",
    props:{
        obj:Object,
//        required:true,
//        default:10
    },
    //props提供的是一个初始化的值，涉及到修改props，就需要data来接
    data(){
        return {
            list:this.obj//直接this就可以拿到props的值，因为它是注册在组件内的
        }
    },
    methods:{
        clickAction(){
            this.$emit('toParent',{id:"I love you, my father !"})
        }
    }
}
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped lang="less">

</style>
